home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 20 / Cream of the Crop 20 (Terry Blount) (1996).iso / os2 / cfspoker.zip / CFSPoker.PKG / CFSGames.CMD < prev    next >
OS/2 REXX Batch file  |  1996-05-09  |  17KB  |  490 lines

  1. /*------------------------------------------------------------------------*\
  2. |                                                                          |
  3. |          CFSGames.CMD - Version 1.0   - Version Date 1995-04-15          |
  4. |               Copyright (C) 1995-96 by C F S Nevada, Inc.                |
  5. |                                                                          |
  6. |                  by Dick Goran  - Voice    702-732-9616                  |
  7. |                                 - FAX      702-732-3847                  |
  8. |                                 - CIS      71154,2002                    |
  9. |                                 - Internet dgoran@cfsrexx.com            |
  10. |                                 - WWW      <http://www.cfsrexx.com>      |
  11. |                                                                          |
  12. \*------------------------------------------------------------------------*/
  13. /*
  14.  
  15.    This program is distributed as part of CFSPoker. Its function is to
  16.    provide maintenance to the CFSPoker INI file by replacing / adding
  17.    game characteristics. If any errors are encountered, the INI file
  18.    is not changed and the appropriate error code (shown below) is
  19.    returned to the calling program.
  20.  
  21.    Detailed instructions for the structure of the CFSPoker.GAM file
  22.    is contained in the CFSPoker.INF file under the heading of
  23.    "CFSPoker.GAM file".
  24.  
  25.    Calling parameters:
  26.    -------------------
  27.    The name of the CFSPoker INI file to receive the maintenance. If not
  28.    specified, CFSPoker.INI in the current directory will be used.
  29.  
  30.    Returns:
  31.    --------
  32.    -4    Unexpected error writing to INI file
  33.    -3    Unexpected error building array of old game names.
  34.    -2    Unexpected error retieving game names from existing INI
  35.          file. This indicates that the INI file is corrupted.
  36.    -1    Unable to locate CFSPoker.GAM file (game characteristics)
  37.    0     Unable to locate INI file
  38.    nn    The number of game entries in the INI file
  39.  
  40. */
  41. GBL. = ''             /* initialize stem */
  42. parse Arg             GBL.command_line
  43. parse Version         GBL.REXX_version,
  44.                       GBL.REXX_version_level,
  45.                       GBL.REXX_version_day,
  46.                       GBL.REXX_version_month,
  47.                       GBL.REXX_version_year .
  48. parse upper Source    GBL.operating_system,
  49.                       GBL.calling_environment,
  50.                       GBL.program_path_and_name
  51. GBL.environment     = 'OS2ENVIRONMENT'
  52. GBL.boot_drive      = LEFT( VALUE( 'RUNWORKPLACE',, GBL.environment ), 2 )
  53. GBL.program_version = 1.0           /* version / mod of this program */
  54. GBL.program_name    = STRIP( FILESPEC( 'N', GBL.program_path_and_name ) )
  55. GBL.program_path    = STRIP( FILESPEC( 'D', GBL.program_path_and_name ) ||,
  56.                              FILESPEC( 'P', GBL.program_path_and_name ) )
  57.  
  58. parse var GBL.program_name,
  59.    GBL.program_fn '.',
  60.    GBL.program_fe
  61.  
  62. /*------------------------*\
  63. |  Enable trap processing  |
  64. \*------------------------*/
  65.    SIGNAL ON ERROR
  66.    SIGNAL ON FAILURE
  67.    SIGNAL ON HALT
  68.    SIGNAL ON NOVALUE
  69.    SIGNAL ON SYNTAX
  70.  
  71. call RxFuncAdd 'SysLoadFuncs', 'REXXUTIL', 'SysLoadFuncs'
  72. call SysLoadFuncs
  73.  
  74. /*----------------------*\
  75. |  Variable definitions  |
  76. \*----------------------*/
  77. GBL.error_counter = 0               /* general error counter */
  78. GBL.error_file    =,
  79.    GBL.program_path ||,
  80.    'CFSGames.ERR'
  81.  
  82. GBL.list =,
  83.    'input_line',
  84.    'input_line_number',
  85.    ''
  86.  
  87. /*----------------------------*\
  88. |  Erase any prior error file  |
  89. \*----------------------------*/
  90. call SysFileDelete GBL.error_file   /* delete if first error */
  91.  
  92. /*---------------------------------*\
  93. |  Assure valid INI file available  |
  94. \*---------------------------------*/
  95. CHECK_FOR_INI_FILE:
  96.  
  97. if GBL.command_line ¬= '' then
  98.    do
  99.       GBL.INI_File =,
  100.          STREAM( GBL.command_line, 'C', 'QUERY EXISTS' )
  101.    end
  102. else
  103.    do
  104.       GBL.INI_File =,
  105.          STREAM( 'CFSPoker.INI', 'C', 'QUERY EXISTS' )
  106.    end
  107. if GBL.INI_file = '' then
  108.    do
  109.       call EOJ 0
  110.    end
  111. GBL.ini_path =,
  112.    FILESPEC( 'D', GBL.INI_file ) ||,
  113.    FILESPEC( 'P', GBL.INI_file ) ||,
  114.    ''
  115.  
  116. /*------------------------------------*\
  117. |  Test for presence of CFSPoker.GAM   |
  118. |  file in same directory as INI file  |
  119. \*------------------------------------*/
  120. CHECK_FOR_GAM_FILE:
  121.  
  122. GBL.GAM_file =,
  123.    STREAM( GBL.INI_path || 'CFSPoker.GAM', 'C', 'QUERY EXISTS' )
  124. if GBL.GAM_file = '' then
  125.    do
  126.       call EOJ -1
  127.    end
  128.  
  129. /*------------------------------------*\
  130. |  Process .GAM file entries building  |
  131. |     array from all valid lines       |
  132. \*------------------------------------*/
  133. READ_AND_PROCESS_GAM_FILE:
  134.  
  135. new_game_table.0  = 0
  136. input_line_number = 0
  137.  
  138. do while LINES( GBL.GAM_file ) > 0
  139.    input_line = LINEIN( GBL.GAM_file )
  140.    input_line_number = input_line_number + 1
  141.  
  142.    /*----------------------------*\
  143.    |  Ignore insignificant lines  |
  144.    \*----------------------------*/
  145.    if input_line = '' then iterate
  146.    first_character_of_input_line = LEFT( input_line, 1 )
  147.    if first_character_of_input_line = ' ',
  148.          |,
  149.       first_character_of_input_line = '*' then iterate
  150.  
  151.    /*-------------------------*\
  152.    |  Check for new game name  |
  153.    \*-------------------------*/
  154.    if first_character_of_input_line = '[' then
  155.       do
  156.          parse value input_line with,
  157.             '[',
  158.             game_name,
  159.             ']'
  160.          if game_name = '' then
  161.             do
  162.                call INPUT_ERROR_ROUTINE '001 Missing game name'
  163.                GBL.ignore_detail_lines_switch = input_line_number
  164.                iterate
  165.             end
  166.          uppercase_game_name = TRANSLATE( game_name )
  167.          if uppercase_game_name = 'WILD',
  168.                |,
  169.             uppercase_game_name = 'COUNTERS' then
  170.             do
  171.                call INPUT_ERROR_ROUTINE '002 Invalid game name'
  172.                GBL.ignore_detail_lines_switch = input_line_number
  173.                iterate
  174.             end
  175.  
  176.          GBL.ignore_detail_lines_switch = ''
  177.  
  178.          n                  = new_game_table.0 + 1
  179.          new_game_table.0   = n
  180.          new_game_table.n   = game_name
  181.          new_game_table.n.0 = 0
  182.          iterate
  183.       end
  184.  
  185.    /*----------------------------------------*\
  186.    |  Ignore detail lines if game name is NG  |
  187.    \*----------------------------------------*/
  188.    if GBL.ignore_detail_lines_switch ¬= '' then
  189.       do
  190.          call INPUT_ERROR_ROUTINE '003 Ignored because of previous error'
  191.          iterate
  192.       end
  193.  
  194.    /*--------------------------*\
  195.    |  Process game detail line  |
  196.    \*--------------------------*/
  197.    line_error_counter = 0
  198.    parse value input_line with,
  199.       hand_title        ';',
  200.       hand_abbreviation ';',
  201.       one_coin_payoff   ';',
  202.       five_coin_payoff  ';'
  203.    hand_title        = STRIP( hand_title )
  204.    hand_abbreviation = TRANSLATE( STRIP( hand_abbreviation ) )
  205.    one_coin_payoff   = STRIP( one_coin_payoff )
  206.    five_coin_payoff  = STRIP( five_coin_payoff )
  207.  
  208.    if TRANSLATE( hand_title ) = 'WILD' then
  209.       do
  210.          line                  = new_game_table.n.0 + 1
  211.          new_game_table.n.0    = line
  212.          new_game_table.n.line = 'WILD' hand_abbreviation
  213.          iterate
  214.       end
  215.  
  216.    if DATATYPE( one_coin_payoff ) ¬= 'NUM' then
  217.       do
  218.          line_error_counter = line_error_counter + 1
  219.       end
  220.    else
  221.       if five_coin_payoff = '' then
  222.          do
  223.             five_coin_payoff = one_coin_payoff * 5
  224.          end
  225.  
  226.    if DATATYPE( five_coin_payoff ) ¬= 'NUM' then
  227.       do
  228.          line_error_counter = line_error_counter + 1
  229.       end
  230.  
  231.    if line_error_counter > 0 then
  232.       do
  233.          call INPUT_ERROR_ROUTINE '004 [' || game_name || ']',
  234.                                   'Error on game characteristic line. ',
  235.                                   'Source line =' RIGHT( input_line_number, 3 )
  236.          GBL.error_counter = GBL.error_counter + 1
  237.          iterate
  238.       end
  239.  
  240.    line                  = new_game_table.n.0 + 1
  241.    new_game_table.n.0    =